package net.mihome.app.bean;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * Created by zhao on 2015/2/10.
 */
public class BuyCar {
    private int id;
    private int uid;
    private int goodsId;
    private int num;
    private String createAt;
    private String updateAt;
    private Goods goods;

    public static List<BuyCar> parseList(List<Map> list){
        if(list!=null){
            List<BuyCar> buyCars=new ArrayList<>();
            Iterator<Map> iterator=list.iterator();
            while(iterator.hasNext()){
                Map map=iterator.next();
                buyCars.add(BuyCar.parse(map));
            }
            return buyCars;
        }else{
            return null;
        }
    }


    public static BuyCar parse(Map map){
        if(map==null){
            return null;
        }
        BuyCar buyCar=new BuyCar();
        Double idStr= (Double) map.get("id");
        if(idStr!=null){
            buyCar.setId(idStr.intValue());
        }
        Double uidStr= (Double) map.get("uid");
        if(uidStr!=null){
            buyCar.setUid(uidStr.intValue());
        }
        Double goodsId= (Double) map.get("goods_id");
        if(goodsId!=null){
            buyCar.setGoodsId(goodsId.intValue());
        }
        Double numStr= (Double) map.get("num");
        if(numStr!=null){
            buyCar.setNum(numStr.intValue());
        }
        if(map.get("goods")!=null){
            buyCar.setGoods(Goods.parse((Map) map.get("goods")) );
        }
        return buyCar;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getUid() {
        return uid;
    }

    public void setUid(int uid) {
        this.uid = uid;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public String getCreateAt() {
        return createAt;
    }

    public void setCreateAt(String createAt) {
        this.createAt = createAt;
    }

    public String getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(String updateAt) {
        this.updateAt = updateAt;
    }

    public Goods getGoods() {
        return goods;
    }

    public void setGoods(Goods goods) {
        this.goods = goods;
    }

    public int getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(int goodsId) {
        this.goodsId = goodsId;
    }
}
